package com.cn.cash.baselib.util;

import android.widget.Toast;

import com.cn.cash.baselib.BaseManager;


public class ToastUtil {
    private static Toast toast;
    public static void show(int res){
        show(BaseManager.getApplication().getResources().getString(res));
    }
    /**
     * Toast 短提示，防止多次提示
     */
    public static void show(String content) {
        if (toast != null) {
            toast.cancel();
        }
        if (ValidatorUtil.isValidString(content)) {
            try {
                toast = Toast.makeText(BaseManager.getApplication(), content, Toast.LENGTH_SHORT);
                toast.show();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    /**
     * Toast 长提示，防止多次提示
     */
    public static void showLong(String content) {
        if (toast != null) {
            toast.cancel();
        }
        if (ValidatorUtil.isValidString(content)) {
            try {
                toast = Toast.makeText(BaseManager.getApplication(), content, Toast.LENGTH_LONG);
                toast.show();
            } catch (Exception e) {
            }
        }
    }
}
